package com.yoooya.base.common;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.yoooya.base.utils.DateUtils;

import java.text.SimpleDateFormat;
import java.util.TimeZone;

/**
 * @创建人 Sun Yijing
 * @创建时间 2018-06-28
 */
public class JacksonObjectMapper extends ObjectMapper {

	public JacksonObjectMapper() {
		this.setTimeZone(TimeZone.getTimeZone("GMT+8"));
		this.setDateFormat(new SimpleDateFormat(DateUtils.DEFAULT_PATTERN));

		this.setSerializationInclusion(JsonInclude.Include.NON_NULL);
		this.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);

		this.configure(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS, true);
		this.configure(JsonGenerator.Feature.QUOTE_NON_NUMERIC_NUMBERS, true);
	}

}
